package com.flyfinger.register;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * @author zhouyp
 * @program code
 * @description
 * @create 2020-06-22
 */
public class CuratorClient {

	public static final String ZK_CLIENT_PATH = "/child-location";

	private static final String NAME_SPACE = "service-location";
	private static final String CONNECT_STRING = "127.0.0.1:2181";

	public static CuratorFramework curator() {
		RetryPolicy retryPolicy =
				new ExponentialBackoffRetry(1000, 3);
		return CuratorFrameworkFactory.builder()
				.connectString(CONNECT_STRING)
				.sessionTimeoutMs(5000)
				.connectionTimeoutMs(5000)
				.retryPolicy(retryPolicy)
				.namespace(NAME_SPACE)
				.build();
	}
}
